package com.tang.component.mysql;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.logging.Level;
import java.util.logging.Logger;

@Configuration
@ConditionalOnWebApplication
public class MybatisConfiguration {

    private static final Logger log = Logger.getLogger(MybatisConfiguration.class.getName());

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(new MybatisPlusAllSqlLog());
        if (log.isLoggable(Level.INFO)) {
            log.info("MySQL-Log-Util has finished to load");
        }
        return mybatisPlusInterceptor;
    }



}
